package com.le.sarrs.web.event;

import org.springframework.http.ResponseEntity;
import reactor.rx.Promise;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Description: Controller发起的event对象 DateTime: 14-5-28 下午3:38
 *
 * @author guoht@youyuan.com
 * @version 1.0
 */
public class ApplicationEvent implements Serializable {

    private static final long serialVersionUID = -225796595506339507L;
    private ContentType contentType;
    private Promise<ResponseEntity<String>> promise;
    private String jspViewName;
    // 当前用户
//    private User user;
    private Map<String, Object> parameters = new HashMap<>();
    private Map<String, Object> results = new HashMap<>();
    private HttpServletRequest request;

    public ContentType getContentType() {
        return contentType;
    }

    public void setContentType(ContentType contentType) {
        this.contentType = contentType;
    }

//    public User getUser() {
//        return user;
//    }
//
//    public void setUser(User user) {
//        this.user = user;
//    }

    public void setParam(String key, Object value) {
        this.parameters.put(key, value);
    }

    public Object getParam(String key) {
        return this.parameters.get(key);
    }

    public Map<String, Object> getAllParam() {
        return this.parameters;
    }

    public Object getResult(String key) {
        return this.results.get(key);
    }

    public void setResult(String key, Object value) {
        this.results.put(key, value);
    }

    public void removeResult(String key) {
        this.results.remove(key);
    }

    public Map<String, Object> getAllResults() {
        return this.results;
    }

    public String getJspViewName() {
        return jspViewName;
    }

    public void setJspViewName(String jspViewName) {
        this.jspViewName = jspViewName;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public Promise<ResponseEntity<String>> getPromise() {
        return promise;
    }

    public void setPromise(Promise<ResponseEntity<String>> promise) {
        this.promise = promise;
    }

}
